package com.controller;

import com.pojo.Order;
import com.util.GetTime;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;


@Controller
public class OrderController {

    @Resource
    private RabbitTemplate rabbitTemplate;

    @GetMapping("/addOrders")
    @ResponseBody
    public String addOrder() {
        Order order = new Order();
        order.setoId(1);
        order.setuId(100);
        order.setTime(GetTime.getTime());

        Order order1 = new Order();
        order1.setoId(2);
        order1.setuId(200);
        order1.setTime(GetTime.getTime());
        rabbitTemplate.convertAndSend("fanoutExchange","success", order);
        rabbitTemplate.convertAndSend("fanoutExchange","error", order1);
        return "order添加测试";
    }

}
